<template>
        <el-dialog @close="emit('close')" v-model="props.show" @open="init" title="请输入新名"  :width="x > 1500 ? '50%' : '90%'">
            <el-input v-model="folderName" autocomplete="off" />
            <template #footer>
                <div class="dialog-footer">
                    <el-button @click="emit('close')">取消</el-button>
                    <el-button type="primary" @click="rename">
                        确认
                    </el-button>
                </div>
            </template>
        </el-dialog>
</template>
<script setup lang="ts">
import { ref ,toRaw,onMounted} from 'vue'
import fileApi from '@/api/file'
const x = window.innerWidth
const props  = defineProps<{
    currentFolder:string,
    show:boolean,
    oldName:string | undefined
}>()
const emit = defineEmits<{
    (e:'close'):void,
    (e:'success'):void
}>()

const folderName = ref('')
function init () {
    folderName.value = props.oldName as string
}
const rename = () => {    
    fileApi.rename(props.oldName as string, folderName.value,props.currentFolder).then(res => {
        emit('success')
    })
}
</script>
<style scoped></style>